# -*- mode: snippet -*-
# name: sdlc
# key: sdlc
# --
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>

#define SDL_WINDOW_WIDTH 800
#define SDL_WINDOW_HIGHT 600

int main(){
    /* SDL Initialization */
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window* window = SDL_CreateWindow("SDL_Tutoriall",
                                          SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                                          SDL_WINDOW_WIDTH, SDL_WINDOW_HIGHT, SDL_WINDOW_SHOWN);

    /* Get window surface */
    SDL_Surface* windowSurface = SDL_GetWindowSurface(window);

    /* Handle sdl event */
    SDL_Event event;
    int quit = 0;
    while(quit == 0){
        while(SDL_PollEvent(&event)){
            if(event.type == SDL_QUIT){
                quit = 1;
            }
            /* Get event for keyboard */
            else if(event.type == SDL_KEYDOWN){
                switch (event.key.keysym.sym) {
                case  SDLK_ESCAPE: {
                    quit = 1;
                    break;
                }
                default:
                    break;
                }
            }

            /* Code write here */
            $1

        }
        SDL_Delay(50);
        SDL_FillRect(windowSurface, NULL, 0);
        SDL_UpdateWindowSurface(window);
    }

    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}